<!DOCTYPE html>
<html>
<head>
    <title>MVVM</title>
    <meta charset="utf-8">
    <link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
    <link href="../../styles/kendo.common.min.css" rel="stylesheet">
    <link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
    <link href="../../styles/kendo.default.min.css" rel="stylesheet">
    <link href="../../styles/kendo.dataviz.min.css" rel="stylesheet">
    <link href="../../styles/kendo.dataviz.default.min.css" rel="stylesheet">
    <link href="../../styles/kendo.mobile.all.min.css" rel="stylesheet" />
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/kendo.all.min.js"></script>
    <script src="../content/shared/js/console.js"></script>
    <script>
        
    </script>
    
    
</head>
<body>
    
        <a class="offline-button" href="../index.html">Back</a>
    
    <div data-model="mobileListViewModel" data-role="view" id="mobile-listview-events" data-title="ListView MVVM">
    <form data-bind="events: { submit: add }">
        <ul data-role="listview" data-style="inset" data-type="group">
            <li>
                Add new item
                <ul>
                    <li><label>Add item: <input type="text" placeholder="item name&hellip;" data-bind="value: newItemValue" /></label></li>
                </ul>
                <button type="submit" class="km-widget km-button" style="display: block; margin: 1em auto; font-size: 1.1em;">Add</button>
            </li>

            <li>
                Items:
                <ul data-role="listview" data-bind="source: source, events { click: onClick }"></ul>
            </li>
            <li>
                Events:
                <ul data-role="listview">
                    <li><div class="console"></div></li>
                </ul>
            </li>
        </ul>

        <p>
            Kendo UI Mobile ListView supports the
            <a href="http://docs.telerik.com/kendo-ui/getting-started/framework/mvvm/bindings/source">source</a>,
            <a href="http://docs.telerik.com/kendo-ui/getting-started/framework/mvvm/bindings/events">events</a> and
            <a href="http://docs.telerik.com/kendo-ui/getting-started/framework/mvvm/bindings/visible">visible</a> bindings.
        </p>
    </form>
    <style scoped>
        .km-ios .km-listview .km-button,
        .km-ios7 .km-listview .km-button,
        .km-blackberry .km-listview .km-button,
        .km-android .km-listview .km-button {
                width: 90%;
            }
        .km-flat .km-listview .km-button,
        .km-wp .km-listview .km-button {
                width: 100%;
            }
    </style>
</div>

<script>
    var mobileListViewModel = kendo.observable({
        source: [ "foo", "bar" ],
        newItemValue: "",
        add: function(e) {
            var val = this.get("newItemValue");
            if (val) {
                this.source.push(val);
            }

            $("#listview-new-item").blur();
            e.preventDefault();
        },

        onClick: function(e) {
            kendoConsole.log("event :: click (" + e.item.text() + ")", false, "#mobile-listview-events");
        }
    });
</script>


    
    <script>
        window.kendoMobileApplication = new kendo.mobile.Application(document.body);
    </script>
    
    
</body>
</html>
